<template>
	<view v-if="pageShow">
		<header-top :messageInfo="{typeFlag:true,message:'消息',liner:true}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content">
					<view class="dingyue" @click="jumpurl('/pages/homepage/news/subscribe')"></view>
				</view>
			</view>
		</header-top>
		<view class="mainpadding">
			<view class="flexleft">
				<view :class="current==2?'selectbox':'noselectbox'" @click="switchtab(2)">代办</view>
				<view :class="current==1?'selectbox':'noselectbox'" @click="switchtab(1)">通知</view>
			</view>
			<!-- 通知 -->
			<view v-show="current==1">
				<view class="margin_top newsflex" v-if="pdShow(1)" @click="jumpurl('/pages/homepage/news/diaodu?type=1')">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news1.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">政策发文</view>
							<view class="newstext margin_top" v-if="dataAll.zcfwinfo">{{dataAll.zcfwinfo.title}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime" v-if="dataAll.zcfwinfo">{{dataAll.zcfwinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.zcfw_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.zcfw_noread_num">{{dataAll.zcfw_noread_num}}</view> -->
					</view>
				</view>
				<view class="margin_top newsflex"  v-if="pdShow(2)" @click="jumpurl('/pages/homepage/news/diaodu?type=2')">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news2.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">公司制度</view>
							<view class="newstext margin_top" v-if="dataAll.gszdinfo">{{dataAll.gszdinfo.title}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime"  v-if="dataAll.gszdinfo">{{dataAll.gszdinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.gszd_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.gszd_noread_num">{{}}</view> -->
					</view>
				</view>
				<view class="margin_top newsflex" v-if="pdShow(3)" @click="jumpurl('/pages/homepage/news/diaodu?type=3')">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news3.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">最新通知</view>
							<view class="newstext margin_top" v-if="dataAll.zxtzinfo">{{dataAll.zxtzinfo.title}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime" v-if="dataAll.zxtzinfo">{{dataAll.zxtzinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.zxtz_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.zxtz_noread_num">{{}}</view> -->
					</view>
				</view>
				<view class="margin_top newsflex" v-if="pdShow(4)" @click="jumpurl('/pages/homepage/news/diaodu?type=4')">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news4.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">平台信息</view>
							<view class="newstext margin_top" v-if="dataAll.ptxxinfo">{{dataAll.ptxxinfo.title}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime"  v-if="dataAll.ptxxinfo">{{dataAll.ptxxinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.ptxx_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.ptxx_noread_num">{{}}</view> -->
					</view>
				</view>
				<view class="margin_top newsflex" v-if="pdShow(5)" @click="jumpurl('/pages/homepage/news/kehuls',55)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news5.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">客户流失预警</view>
							<view class="newstext margin_top" v-if="dataAll.khlsinfo">{{dataAll.khlsinfo.notes}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime" v-if="dataAll.khlsinfo">{{dataAll.khlsinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.khls_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.khls_noread_num">{{}}</view> -->
					</view>
				</view>
				<view class="margin_top newsflex" v-if="pdShow(6)" @click="jumpurl('/pages/homepage/news/kucun',97)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news6.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">仓库预警</view>
							<view class="newstext margin_top" v-if="dataAll.ckyjinfo">{{dataAll.ckyjinfo.notes}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime" v-if="dataAll.ckyjinfo">{{dataAll.ckyjinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.ckyj_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.ckyj_noread_num">{{}}</view> -->
					</view>
				</view>
				<view class="margin_top newsflex" v-if="pdShow(7)" @click="jumpurl('/pages/workbench/kucun/pandiandmxcx',101)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news7.png" mode=""></image>
						</view>
						<view>
							<view class="titletext">盘点单</view>
							<view class="newstext margin_top" v-if="dataAll.pddinfo">{{dataAll.pddinfo.title}}</view>
						</view>
					</view>
					<view class="flexcolumnright">
						<view class="newstime" v-if="dataAll.pddinfo">{{dataAll.pddinfo.createtime_text}}</view>
						<u-badge max="99" :value="dataAll.pdd_noread_num"></u-badge>
						<!-- <view class="jiaobiao" v-show="dataAll.pdd_noread_num">{{}}</view> -->
					</view>
				</view>

			</view>
			<!-- 代办 -->
			<view v-show="current==2">
				<view class="margin_top newsflex" v-if="pdShow(10)" @click="jumpurl('/pages/workbench/xiaoshou/xiaoshouddcx?type=10',37)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news10.png" mode=""></image>
						</view>
						<view class="titletext">销售单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.sale_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.sale_order_num">{{dataAll.sale_order_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(12)" @click="jumpurl('/pages/workbench/kucun/chukudancx?type=10',111)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news12.png" mode=""></image>
						</view>
						<view class="titletext">出库单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.outbound_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.outbound_order_num">{{dataAll.outbound_order_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(13)" @click="jumpurl('/pages/workbench/kucun/rukudancx?type=10',104)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news13.png" mode=""></image>
						</view>
						<view class="titletext">入库单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.warehousing_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.warehousing_order_num">{{dataAll.warehousing_order_num}}
					</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(11)" @click="jumpurl('/pages/workbench/xiaoshou/tuihuodcx?type=10',46)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news11.png" mode=""></image>
						</view>
						<view class="titletext">销售退货单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.saleth_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.saleth_order_num">{{dataAll.saleth_order_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(8)" @click="jumpurl('/pages/workbench/caigou/caigoudcx?type=10',23)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news8.png" mode=""></image>
						</view>
						<view class="titletext">采购单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.procure_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.procure_order_num">{{dataAll.procure_order_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(9)" @click="jumpurl('/pages/workbench/caigou/caigouthdcx?type=10',30)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news9.png" mode=""></image>
						</view>
						<view class="titletext">采购退货单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.procureth_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.procureth_order_num">{{dataAll.procureth_order_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(16)" @click="jumpurl('/pages/workbench/caiwu/feiyongcx?type=10',80)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news15.png" mode=""></image>
						</view>
						<view class="titletext">费用支出审核</view>
					</view>
					<u-badge max="99" :value="dataAll.fyzc_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.fyzc_num">{{dataAll.fyzc_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(14)" @click="jumpurl('/pages/workbench/kucun/kucundbcx?type=10',94)">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news14.png" mode=""></image>
						</view>
						<view class="titletext">调拨单审核</view>
					</view>
					<u-badge max="99" :value="dataAll.dbd_order_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.dbd_order_num">{{dataAll.dbd_order_num}}</view> -->
				</view>
				<view class="margin_top newsflex" v-if="pdShow(15)" @click="jumpurl('/pages/workbench/xiaoshou/shenpijl?type=10')">
					<view class="flexleft">
						<view class="lefticon">
							<image src="@/static/image/news/news15.png" mode=""></image>
						</view>
						<view class="titletext">请假审核</view>
					</view>
					<u-badge max="99" :value="dataAll.qj_num"></u-badge>
					<!-- <view class="jiaobiao" v-show="dataAll.qj_num">{{dataAll.qj_num}}</view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				current: 2,
				dataAll: {},
				pageShow: false,
				qxids:[],
				flag:true
			}
		},
		onLoad() {
			uni.hideTabBar(); //隐藏tab
		},
		onShow() {
			this.init()
			if(uni.getStorageSync("newsflag")){
				this.flag = true
				this.qxids = JSON.parse(uni.getStorageSync("newslist"))
			}else{
				this.flag = false
			}
		},
		methods: {
			init() {
				httpRequest.request('/dhtapi/index/newsNoReadNum', 'GET', {}).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				}).catch(err => {
					httpRequest.toast(err.msg)
				})
			},
			pdShow(id){
				if(this.flag){
					let num = this.qxids.lastIndexOf(id)
					console.log(num,9999999999999889787);
					if(num===-1){
						return false
					}else{
						return true
					}
				}else{
					return true
				}
				
				
			},
			// tab切换
			switchtab(i) {
				this.current = i
			},
			jumpurl(url, qxpdid) {
				if (qxpdid) {
					if (!httpRequest.qxpd(qxpdid, this.$store.state.userInfo.ability_rule_ids)) {
						return false
					}
				}
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.dingyue {
		width: 42rpx;
		height: 60rpx;
		background-image: url("@/static/image/system/dingyue.png");
		background-size: 100% 100%;
	}

	// 顶部tab
	.selectbox {
		padding: 6rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #0BBDCB;
		line-height: 33rpx;
		background-color: #e1f4f5;
		border-radius: 30rpx;
		margin-right: 30rpx;
	}

	.noselectbox {
		padding: 6rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #999999;
		line-height: 33rpx;
		background-color: #eff0f0;
		border-radius: 30rpx;
		margin-right: 30rpx;
	}

	// 信息
	.newsflex {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		padding: 30rpx 0;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.02);
	}

	.lefticon {
		width: 84rpx;
		height: 84rpx;
		min-width: 84rpx;
		max-width: 84rpx;
		margin-right: 20rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.newstext {
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		color: #666666;
		width: 300rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		line-height: 24rpx;
	}

	.newstime {
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		color: #999;
		line-height: 24rpx;
		margin-bottom: 30rpx;
	}

	.xiankuan {
		width: 300rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.flexcolumnright {
		display: flex;
		align-items: flex-end;
		flex-direction: column;
	}

	.jiaobiao {
		margin-top: 30rpx;
		background-color: #ff0000;
		border-radius: 10rpx;
		color: #fff;
		width: 50rpx;
		padding: 5rpx 0;
		text-align: center;
		line-height: 16rpx;
		font-size: 16rpx;
	}
</style>